﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LeadTrackerMVC.Models;

namespace LeadTrackerMVC.Controllers
{
	public class HomeController : Controller
	{
		public ActionResult Index()
		{
			if (User != null && User.Identity.IsAuthenticated)
				return RedirectToAction("Dashboard");

			ViewBag.Message = "Welcome to ASP.NET MVC!";

			return View();
		}

		[Authorize]
		public ActionResult Dashboard()
		{
			var data = MvcApplication.LeadRepository.GetActiveLeads();
			var model = new DashboardModel(MvcApplication.UserEditorKey, data.Leads, data.Editors);
			return View(model);
		}

		public ActionResult About()
		{
			return View();
		}
	}
}
